package com.ruoyi.crm.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.Mongolog;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.domain.Clue;
import com.ruoyi.crm.domain.vo.ClueTrackVo;
import com.ruoyi.crm.domain.vo.FalseClueVo;
import com.ruoyi.crm.domain.vo.TransfromVo;
import com.ruoyi.crm.service.IClueService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/crm/clueTrack")
public class ClueTrackControler extends BaseController {

    @Resource
    private IClueService clueService;


//    @Log(title = "线索跟踪记录")
    @Mongolog(tableName = Mongolog.TableName.CLUE,title = "线索跟踪记录",businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClueTrackVo vo){
        vo.setStatus(Clue.Status.TRACKING.getValue());
        return toAjax(clueService.updateClue(vo));

    }


    //伪线索上报
//    @Log(title = "线索跟踪记录")
    @Mongolog(tableName = Mongolog.TableName.CLUE,title = "线索跟踪记录",businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult falsetrack(@RequestBody FalseClueVo vo){

        return toAjax(clueService.falseClue(vo.getId()));
    }
//    @Log(title = "线索跟踪记录")
    @Mongolog(tableName = Mongolog.TableName.CLUE,title = "线索跟踪记录",businessType = BusinessType.UPDATE)
    @PutMapping("/transform")
    public AjaxResult transform(@RequestBody TransfromVo transfromVo){
        return toAjax(clueService.transform(transfromVo.getId()));
    }
//    @Log(title = "线索跟踪记录")
    @Mongolog(tableName = Mongolog.TableName.CLUE,title = "线索跟踪记录",businessType = BusinessType.UPDATE)
    @PutMapping("/resetClue")
    public AjaxResult resetClue(@RequestBody TransfromVo transfromVo){
        return toAjax(clueService.resetClue(transfromVo.getId()));
    }
}
